<?php
require_once("db.php");

//---------------------------
// MakeFastestTimesTable
//---------------------------
function MakeFastestTimesTable($userid=-1)
{
	$fastest = GetFastestTimes($userid);
	
	$ret_str = "";

	if($fastest != FALSE){

		$ret_str .= "<table border='1' cellpadding='10' width='600' align='center'>\n";
		$ret_str .= "	<tr>\n";
		if($userid==-1){
			$ret_str .= "		<th class='color11' colspan='3'><font size='+2'>Fastest times solving 100 problems correctly!</font></th>\n";
		}else{
			$ret_str .= "		<th class='color11' colspan='2'><font>Your fastest times solving 100 problems correctly!</font></th>\n";
		}
		$ret_str .= "	</tr>\n";
		$ret_str .= "	<tr class='color2'>\n";
		if($userid==-1)$ret_str .= "		<th>Who?</th>\n";
		$ret_str .= "		<th>How Fast?</th>\n";
		$ret_str .= "		<th>When?</th>\n";
		$ret_str .= "	</tr>\n";

		foreach($fastest AS $row){
			$minutes = floor($row["time_seconds"]/60.0);
			$seconds = $row["time_seconds"] - $minutes*60.0;
			$ret_str .= "		<tr>\n";
			if($userid==-1)$ret_str .= "			<td align='center'>".$row["first_name"]."</td>\n";
			$ret_str .= "			<td align='center'>${minutes}m ${seconds}s</td>\n";
			$ret_str .= "			<td align='center'>".$row["time_completed"]."</td>\n";
			$ret_str .= "		</tr>\n";
		}
		$ret_str .= "</table>\n";
	}else{
		if($userid==-1){
			$ret_str = "No one has gotten a perfect score on a 100 problem test yet!<br>\n";
		}else{
			$ret_str = "You have not yet gotten a perfect score on a 100 problem test! Keep trying!<br>\n";
		}
	}
	
	return $ret_str;
}
?>